/*************************************************************************
> File Name: 05_test.cpp
> Author: hzy
> Created Time: 2023-08-16 19:36:43
> Description: 类模板的友元函数模板
************************************************************************/
#include <iostream>

using namespace std;

template <class T>
class Demo
{
private:
    T Val;

public:
    Demo(T Val);

    template <class U>
    friend void showVal(const Demo<U> &obj);
};

template <class T>
Demo<T>::Demo(T myVal)
{
    Val = myVal;
}

template <class U>
void showVal(const Demo<U> &obj)
{
    cout << obj.Val << endl;
}

int main()
{
    Demo<int> obj(6);
    showVal(obj);

    Demo<string> obj2("啦啦啦啦啦啦啦");
    showVal(obj2);

    return 0;
}
